def listTest():
    my_list = [21, 25, 21, 23, 22, 20]
    new_list = [29, 33, 30]
    my_list.append(31)
    print("追加一个数字31：", my_list)
    my_list.extend(new_list)
    print("追加一个新列表：", my_list)
    firstItem = my_list.pop(0)
    print("取出第一个元素：：", firstItem)
    lastItem = my_list.pop(-1)
    print("取出最后一个元素：：", lastItem)
    print("31的下标位置是", my_list.index(31))
    print(my_list)


def tupleTest():
    info = ("周杰伦", 11, ["football", "music"])
    coding = ["coding"]
    name = info[0]
    age = info[1]
    print(f"姓名：{name}，年龄：{age}")
    info[2][0:1] = coding
    print(info)


def stringTest():
    my_str = "itheima itcast boxuegu"
    countStr = my_str.count("it")
    print(countStr)
    repStr = my_str.replace(" ", "|")
    print(repStr)
    strList = repStr.split("|")
    print(strList)


def sliceTset():
    sliceStr = "学Python,来黑马程序员,月薪过万"
    endStr=sliceStr[::-1]
    strList=endStr.split(",")
    newStr=strList[1][::-1].strip("来")
    print(newStr)


def setText(myList):
   # 方法1：mySet = set(myList)
   # 方法2：mySet={item for item in myList}
   # 方法3：
   mySet = set()
   for item in myList: mySet.add(item)
   # 方法4： mySet=set(map(lambda name:name,myList))
   # 方法5： mySet={*myList}
   print(f"集合类容：{mySet},类型为{type(mySet)},长度为{len(mySet)}")


def dictText(staffInfo):
    """
    级别上升1级 ，薪水增加1000
    :param staffInfo:
    :return:
    """
    for key in staffInfo:
        if  staffInfo[key]["grade"]==1:
            staffInfo[key]["grade"]+=1
            staffInfo[key]["wage"]+=1000

def addStaffFunc(tag,info):
    """
    添加员工信息
    :param tag:
    :param info:
    :return:
    """
    global  staffInfo
    name={}
    for index in range(4):
        name[tag[index]] = info[index]

    staffInfo[name["name"]] = name

staffInfo={}

tag=["name", "dept", "wage","grade"]
xzqList=["薛之谦","科技部",3000,1]
wlhList=["王力宏","科技部",3000,1]
zjlList=["周杰伦","市场部",5000,2]
ljjList=["林俊杰","市场部",7000,3]
zxyList=["张学友","科技部",4000,1]
ldhList=["刘德华","市场部",6000,2]
addStaffFunc(tag,xzqList)
addStaffFunc(tag,wlhList)
addStaffFunc(tag,zjlList)
addStaffFunc(tag,ljjList)
addStaffFunc(tag,zxyList)
addStaffFunc(tag,ldhList)

print(staffInfo)
dictText(staffInfo)
print(staffInfo)






